<template>
	<view>
		<view style="height: 80upx;line-height: 80upx;background-color: #F1F1F1;color: #aaa;margin-left: 20upx;">
			推荐商品
		</view>
		<view style="min-height: 1800upx;background-color: #fff;" >
			<view 
				style="height: 120upx;line-height: 100upx;display: flex;border-bottom: 1upx solid #ccc;padding: 10upx 10upx;"
				v-for="(item, index) in topicList" :key="index"
				@click="select(item.id,item.goods_name)"
			>
				<image style="height: 100upx;width: 100upx;margin-right: 50upx;" :src="item.goods_thumb_image" mode=""></image>
				<text>#{{item.goods_name}}#</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user_id:'',
				res:[],
				topicList:[],
			}
		},
		onLoad() {
			uni.getStorage({
				key: 'user_id',
				success: (res) => {
				 this.user_id = res.data
				 this.setAjax()
				},
			});
		},
		methods: {
			setAjax(){
				let o = this
				uni.request({
					url: 'https://cx.mingmeijt.com/Api/Goods/index',
					method: 'POST',
					data:{
						user_id: this.user_id,
						session_id: uni.getStorageSync("sessionid")
					},
					header:{'Content-Type':'form-data'},
					success: (res) => {
						if(res.data.code == 999){
							uni.navigateTo({
								url:'/pages/999/999'
							})
						};
						this.topicList = res.data.data.list
						for (let i = 0; i < this.topicList.length; i++ ) {
							this.topicList[i].goods_thumb_image = 'https://cx.mingmeijt.com' + this.topicList[i].goods_thumb_image
						}
					}
				});
				uni.hideLoading()
			},
			select(id,name) {
				uni.navigateTo({
					url: '../details/details?goods_id=' + id + '&goods_name=' + name
				})
			},
		}
	}
</script>

<style>

</style>

